﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Aden.Model;
using Aden.Model.SFEED;
using Aden.DAL.SOAccount;
using Aden.DAL.SFEED;
using System.Data;
using Aden.Util.Database;
using System.Reflection.Emit;

namespace Aden.BLL.SFEED
{
    public class SFEEDHelper
    {
        private readonly static SFEEDFactory SFEEDFactory = new SFEEDFactory();

        public static bool CheckWechatLoginUser(string wechatId)
        {
            try
            {
                bool CheckWechatLoginUser = SFEEDFactory.CheckWechatLoginUser(wechatId);
                return CheckWechatLoginUser;
            }
            catch (Exception ex)
            {
                LogHelper.WriteLog(new Log()
                {
                    message = ex.Message
                }, "CheckWechatLoginUser");
                return false;
            }
        }

        public static dynamic GetWechatMenuList(string wechatId)
        {
            try
            {
                dynamic WechatMenuList = SFEEDFactory.GetWechatMenuList(wechatId);
                return WechatMenuList;
            }
            catch(Exception ex)
            {
                LogHelper.WriteLog(new Log()
                {
                    message = ex.Message
                }, "GetWechatMenuList");
                return false;
            }
        }

        public static List<SaleOrder> GetSODatas(string maxOrderId, string siteGuid, string orderDate, string orderstatus, string orderCode, string language)
        {
            try
            {
                List<SaleOrder> GetSOList = SFEEDFactory.GetSOList(maxOrderId, siteGuid, orderDate, orderstatus, orderCode, language);
                if (GetSOList == null || !GetSOList.Any()) return null;
                return GetSOList;
            }
            catch (Exception ex)
            {
                LogHelper.WriteLog(new Log()
                {
                    message = ex.Message
                }, "GetSOList");
                return null;
            }
        }

        public static int UpdateSOStatus(string headGuid, string orderstatus, string userID)
        {
            try
            {
                int GetSOList = SFEEDFactory.UpdateSOStatus(new List<SaleOrder>() { new SaleOrder() { HeadGUID = headGuid } },
                orderstatus, userID);
                if (GetSOList == 0) return 0;
                return GetSOList;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

    }
}
